package com.example.base;

public class LotteryArray {
    public static void main(String[] args) {
        final int NMAX = 10;
        //初始化数组
        int[][] odds = new int[NMAX + 1][];
        for(int i = 0; i <= NMAX; i++){
            odds[i] = new int[i + 1];
        }
        //填充数据
        for(int i = 0; i < odds.length; i++){
            for(int j = 0; j < odds[i].length; j++){
                int lotteryOdds = 1;
                for(int k = 1; k <= j; k++){
                    lotteryOdds = lotteryOdds * (i - k + 1) / k;
                }
                odds[i][j] = lotteryOdds;
            }
        }

        for(int[] row : odds){
            for(int odd : row){
                System.out.printf("%4d", odd);
            }
            System.out.println();
        }
    }
}
/*
   1
   1   1
   1   2   1
   1   3   3   1
   1   4   6   4   1
   1   5  10  10   5   1
   1   6  15  20  15   6   1
   1   7  21  35  35  21   7   1
   1   8  28  56  70  56  28   8   1
   1   9  36  84 126 126  84  36   9   1
   1  10  45 120 210 252 210 120  45  10   1
 */